/*
 * AdministrarLinea.java
 *
 * Created on 15-oct-2008, 13:47:09
 */
 
package investigaciones_itm.LineasInvestigacion;

import com.sun.rave.faces.data.DefaultSelectItemsArray;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.HiddenField;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.MessageGroup;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.PageSeparator;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.Tab;
import com.sun.webui.jsf.component.TabSet;
import javax.faces.FacesException;
import investigaciones_itm.SessionBean1;
import investigaciones_itm.RequestBean1;
import investigaciones_itm.ApplicationBean1;
import itm.bo.lineaInvestigacion.LineaInvestigacionBO;
import itm.vo.lineaInvestigacion.EstadoComplementoLineaInvVO;
import itm.vo.lineaInvestigacion.LineaInvestigacionVO;
import itm.vo.lineaInvestigacion.ParAcademicoVO;
import itm.vo.personas.PersonaVO;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlInputTextarea;
import javax.faces.component.html.HtmlMessages;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.model.SelectItem;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Administrador
 */
public class AdministrarLinea extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }

    private Page page1 = new Page();
    
    public Page getPage1() {
        return page1;
    }
    
    public void setPage1(Page p) {
        this.page1 = p;
    }
    
    private Html html1 = new Html();
    
    public Html getHtml1() {
        return html1;
    }
    
    public void setHtml1(Html h) {
        this.html1 = h;
    }
    
    private Head head1 = new Head();
    
    public Head getHead1() {
        return head1;
    }
    
    public void setHead1(Head h) {
        this.head1 = h;
    }
    
    private Link link1 = new Link();
    
    public Link getLink1() {
        return link1;
    }
    
    public void setLink1(Link l) {
        this.link1 = l;
    }
    
    private Body body1 = new Body();
    
    public Body getBody1() {
        return body1;
    }
    
    public void setBody1(Body b) {
        this.body1 = b;
    }
    
    private Form form1 = new Form();
    
    public Form getForm1() {
        return form1;
    }
    
    public void setForm1(Form f) {
        this.form1 = f;
    }
    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }
    private TabSet tabSet1 = new TabSet();

    public TabSet getTabSet1() {
        return tabSet1;
    }

    public void setTabSet1(TabSet ts) {
        this.tabSet1 = ts;
    }
    private Tab tab1 = new Tab();

    public Tab getTab1() {
        return tab1;
    }

    public void setTab1(Tab t) {
        this.tab1 = t;
    }
    private PanelLayout layoutPanel1 = new PanelLayout();

    public PanelLayout getLayoutPanel1() {
        return layoutPanel1;
    }

    public void setLayoutPanel1(PanelLayout pl) {
        this.layoutPanel1 = pl;
    }
    private Tab tab2 = new Tab();

    public Tab getTab2() {
        return tab2;
    }

    public void setTab2(Tab t) {
        this.tab2 = t;
    }
    private PanelLayout layoutPanel2 = new PanelLayout();

    public PanelLayout getLayoutPanel2() {
        return layoutPanel2;
    }

    public void setLayoutPanel2(PanelLayout pl) {
        this.layoutPanel2 = pl;
    }
    private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel2() {
        return gridPanel2;
    }

    public void setGridPanel2(HtmlPanelGrid hpg) {
        this.gridPanel2 = hpg;
    }
    private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel3() {
        return gridPanel3;
    }

    public void setGridPanel3(HtmlPanelGrid hpg) {
        this.gridPanel3 = hpg;
    }
    private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel4() {
        return gridPanel4;
    }

    public void setGridPanel4(HtmlPanelGrid hpg) {
        this.gridPanel4 = hpg;
    }
    private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel5() {
        return gridPanel5;
    }

    public void setGridPanel5(HtmlPanelGrid hpg) {
        this.gridPanel5 = hpg;
    }
    private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel6() {
        return gridPanel6;
    }

    public void setGridPanel6(HtmlPanelGrid hpg) {
        this.gridPanel6 = hpg;
    }
    private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel7() {
        return gridPanel7;
    }

    public void setGridPanel7(HtmlPanelGrid hpg) {
        this.gridPanel7 = hpg;
    }
    private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel8() {
        return gridPanel8;
    }

    public void setGridPanel8(HtmlPanelGrid hpg) {
        this.gridPanel8 = hpg;
    }
    private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel9() {
        return gridPanel9;
    }

    public void setGridPanel9(HtmlPanelGrid hpg) {
        this.gridPanel9 = hpg;
    }
    private HtmlOutputText outputObs = new HtmlOutputText();

    public HtmlOutputText getOutputObs() {
        return outputObs;
    }

    public void setOutputObs(HtmlOutputText hot) {
        this.outputObs = hot;
    }
    private HtmlInputTextarea textAreaObs = new HtmlInputTextarea();

    public HtmlInputTextarea getTextAreaObs() {
        return textAreaObs;
    }

    public void setTextAreaObs(HtmlInputTextarea hit) {
        this.textAreaObs = hit;
    }
    private HtmlOutputText outputfecha = new HtmlOutputText();

    public HtmlOutputText getOutputfecha() {
        return outputfecha;
    }

    public void setOutputfecha(HtmlOutputText hot) {
        this.outputfecha = hot;
    }
    private Calendar calendarFechaObs = new Calendar();

    public Calendar getCalendarFechaObs() {
        return calendarFechaObs;
    }

    public void setCalendarFechaObs(Calendar c) {
        this.calendarFechaObs = c;
    }
    private HtmlCommandButton botonObservaciones = new HtmlCommandButton();

    public HtmlCommandButton getBotonObservaciones() {
        return botonObservaciones;
    }

    public void setBotonObservaciones(HtmlCommandButton hcb) {
        this.botonObservaciones = hcb;
    }
    private HtmlPanelGrid gridPanel10 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel10() {
        return gridPanel10;
    }

    public void setGridPanel10(HtmlPanelGrid hpg) {
        this.gridPanel10 = hpg;
    }
    private HtmlCommandButton botonAprobar = new HtmlCommandButton();

    public HtmlCommandButton getBotonAprobar() {
        return botonAprobar;
    }

    public void setBotonAprobar(HtmlCommandButton hcb) {
        this.botonAprobar = hcb;
    }
    private HtmlCommandButton botonRechazar = new HtmlCommandButton();

    public HtmlCommandButton getBotonRechazar() {
        return botonRechazar;
    }

    public void setBotonRechazar(HtmlCommandButton hcb) {
        this.botonRechazar = hcb;
    }
    private HtmlPanelGrid gridPanel13 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel13() {
        return gridPanel13;
    }

    public void setGridPanel13(HtmlPanelGrid hpg) {
        this.gridPanel13 = hpg;
    }
    private HtmlPanelGrid gridPanel14 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel14() {
        return gridPanel14;
    }

    public void setGridPanel14(HtmlPanelGrid hpg) {
        this.gridPanel14 = hpg;
    }
    private HtmlPanelGrid gridPanel15 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel15() {
        return gridPanel15;
    }

    public void setGridPanel15(HtmlPanelGrid hpg) {
        this.gridPanel15 = hpg;
    }
    private HtmlPanelGrid gridPanel17 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel17() {
        return gridPanel17;
    }

    public void setGridPanel17(HtmlPanelGrid hpg) {
        this.gridPanel17 = hpg;
    }
    private HtmlPanelGrid gridPanel18 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel18() {
        return gridPanel18;
    }

    public void setGridPanel18(HtmlPanelGrid hpg) {
        this.gridPanel18 = hpg;
    }
    private HtmlPanelGrid gridPanel20 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel20() {
        return gridPanel20;
    }

    public void setGridPanel20(HtmlPanelGrid hpg) {
        this.gridPanel20 = hpg;
    }
    private HtmlPanelGrid gridPanel21 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel21() {
        return gridPanel21;
    }

    public void setGridPanel21(HtmlPanelGrid hpg) {
        this.gridPanel21 = hpg;
    }
    private HtmlPanelGrid gridPanel23 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel23() {
        return gridPanel23;
    }

    public void setGridPanel23(HtmlPanelGrid hpg) {
        this.gridPanel23 = hpg;
    }
    private HtmlPanelGrid gridPanel24 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel24() {
        return gridPanel24;
    }

    public void setGridPanel24(HtmlPanelGrid hpg) {
        this.gridPanel24 = hpg;
    }
    private HtmlOutputText outputCloseAct = new HtmlOutputText();

    public HtmlOutputText getOutputCloseAct() {
        return outputCloseAct;
    }

    public void setOutputCloseAct(HtmlOutputText hot) {
        this.outputCloseAct = hot;
    }
    private HtmlOutputText outputAutAct = new HtmlOutputText();

    public HtmlOutputText getOutputAutAct() {
        return outputAutAct;
    }

    public void setOutputAutAct(HtmlOutputText hot) {
        this.outputAutAct = hot;
    }
    private HtmlOutputText outputFecAct = new HtmlOutputText();

    public HtmlOutputText getOutputFecAct() {
        return outputFecAct;
    }

    public void setOutputFecAct(HtmlOutputText hot) {
        this.outputFecAct = hot;
    }
    private HtmlCommandButton buttonActiv = new HtmlCommandButton();

    public HtmlCommandButton getButtonActiv() {
        return buttonActiv;
    }

    public void setButtonActiv(HtmlCommandButton hcb) {
        this.buttonActiv = hcb;
    }
    private HtmlCommandButton botonCancelar = new HtmlCommandButton();

    public HtmlCommandButton getBotonCancelar() {
        return botonCancelar;
    }

    public void setBotonCancelar(HtmlCommandButton hcb) {
        this.botonCancelar = hcb;
    }
    private HtmlInputTextarea textComentarios = new HtmlInputTextarea();

    public HtmlInputTextarea getTextComentarios() {
        return textComentarios;
    }

    public void setTextComentarios(HtmlInputTextarea hit) {
        this.textComentarios = hit;
    }
    private HtmlSelectOneListbox listAutoriza = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListAutoriza() {        
        return listAutoriza;
    }

    public void setListAutoriza(HtmlSelectOneListbox hsol) {
        this.listAutoriza = hsol;
    }
    private DefaultSelectItemsArray listbox1DefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems() {
        return listbox1DefaultItems;
    }

    public void setListbox1DefaultItems(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems = dsia;
    }
    private UISelectItems listbox1SelectItems = new UISelectItems();

    public UISelectItems getListbox1SelectItems() {
        return listbox1SelectItems;
    }

    public void setListbox1SelectItems(UISelectItems uisi) {
        this.listbox1SelectItems = uisi;
    }
    private Calendar calendarActivacion = new Calendar();

    public Calendar getCalendarActivacion() {
        return calendarActivacion;
    }

    public void setCalendarActivacion(Calendar c) {
        this.calendarActivacion = c;
    }
    private HtmlCommandButton botonDesactivar = new HtmlCommandButton();

    public HtmlCommandButton getBotonDesactivar() {
        return botonDesactivar;
    }

    public void setBotonDesactivar(HtmlCommandButton hcb) {
        this.botonDesactivar = hcb;
    }
    private PageSeparator pageSeparator1 = new PageSeparator();

    public PageSeparator getPageSeparator1() {
        return pageSeparator1;
    }

    public void setPageSeparator1(PageSeparator ps) {
        this.pageSeparator1 = ps;
    }
    private HiddenField hiddenIdLinea = new HiddenField();

    public HiddenField getHiddenIdLinea() {
        return hiddenIdLinea;
    }

    public void setHiddenIdLinea(HiddenField hf) {
        this.hiddenIdLinea = hf;
    }
    private HtmlPanelGrid gridPanel25 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel25() {
        return gridPanel25;
    }

    public void setGridPanel25(HtmlPanelGrid hpg) {
        this.gridPanel25 = hpg;
    }
    private HtmlOutputText labelRechazar = new HtmlOutputText();

    public HtmlOutputText getLabelRechazar() {
        return labelRechazar;
    }

    public void setLabelRechazar(HtmlOutputText hot) {
        this.labelRechazar = hot;
    }
    private HtmlPanelGrid gridPanel26 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel26() {
        return gridPanel26;
    }

    public void setGridPanel26(HtmlPanelGrid hpg) {
        this.gridPanel26 = hpg;
    }
    private HtmlPanelGrid gridPanel27 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel27() {
        return gridPanel27;
    }

    public void setGridPanel27(HtmlPanelGrid hpg) {
        this.gridPanel27 = hpg;
    }
    private HtmlPanelGrid gridPanel28 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel28() {
        return gridPanel28;
    }

    public void setGridPanel28(HtmlPanelGrid hpg) {
        this.gridPanel28 = hpg;
    }
    private HtmlPanelGrid gridPanel29 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel29() {
        return gridPanel29;
    }

    public void setGridPanel29(HtmlPanelGrid hpg) {
        this.gridPanel29 = hpg;
    }
    private HtmlPanelGrid gridPanel30 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel30() {
        return gridPanel30;
    }

    public void setGridPanel30(HtmlPanelGrid hpg) {
        this.gridPanel30 = hpg;
    }
    private HtmlOutputText outputText1 = new HtmlOutputText();

    public HtmlOutputText getOutputText1() {
        return outputText1;
    }

    public void setOutputText1(HtmlOutputText hot) {
        this.outputText1 = hot;
    }
    private HtmlOutputText outputText2 = new HtmlOutputText();

    public HtmlOutputText getOutputText2() {
        return outputText2;
    }

    public void setOutputText2(HtmlOutputText hot) {
        this.outputText2 = hot;
    }
    private HtmlInputTextarea areaMotivoRechazo = new HtmlInputTextarea();

    public HtmlInputTextarea getAreaMotivoRechazo() {
        return areaMotivoRechazo;
    }

    public void setAreaMotivoRechazo(HtmlInputTextarea hit) {
        this.areaMotivoRechazo = hit;
    }
    private HtmlInputText textFechaRechazo = new HtmlInputText();

    public HtmlInputText getTextFechaRechazo() {
        textFechaRechazo = new HtmlInputText();
        java.util.Date fechaActual = new java.util.Date();
        fechaActivacion = new Date(fechaActual.getTime());
        textFechaRechazo.setValue(fechaActivacion);
        return textFechaRechazo;
    }

    public void setTextFechaRechazo(HtmlInputText hit) {
        this.textFechaRechazo = hit;
    }
    private HtmlCommandButton botonCancelar1 = new HtmlCommandButton();

    public HtmlCommandButton getBotonCancelar1() {
        return botonCancelar1;
    }

    public void setBotonCancelar1(HtmlCommandButton hcb) {
        this.botonCancelar1 = hcb;
    }
    private HtmlMessages messageList1 = new HtmlMessages();

    public HtmlMessages getMessageList1() {
        return messageList1;
    }

    public void setMessageList1(HtmlMessages hm) {
        this.messageList1 = hm;
    }
    private HtmlMessages messageList2 = new HtmlMessages();

    public HtmlMessages getMessageList2() {
        return messageList2;
    }

    public void setMessageList2(HtmlMessages hm) {
        this.messageList2 = hm;
    }

    // </editor-fold>

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public AdministrarLinea() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here
        
        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("AdministrarLinea Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
        LineaInvestigacionVO lineaInvVO = getRequestBean1().getLineaInvVO();
        lineaInvBO = new LineaInvestigacionBO();
        hiddenIdLinea.setValue(lineaInvVO.getIdLinea());
        try{
            String resultado="";
            resultado=lineaInvBO.consultarEstadoLinea(lineaInvVO);
            
            listaPares = new ArrayList<ParAcademicoVO>();
            lineaInvBO = new LineaInvestigacionBO();
            List collection = new ArrayList();
            int idPar=0;
            String nombrePar="";
            listaPares=lineaInvBO.listarPersonasActivacionLinea(lineaInvVO);
            collection.add(new SelectItem(0, "Seleccione un Integrante"));
            for (int i=0; i<listaPares.size();i++) {
                idPar =listaPares.get(i).getIdParAcademico();
                nombrePar= listaPares.get(i).getNombreParAcademico();
                collection.add(new SelectItem(idPar, nombrePar));
            } // end for 
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            getListAutoriza().getChildren().add(listaMenu);
            
            if(resultado.equals("RECHAZADA")){
                textAreaObs.setReadonly(true);
                calendarFechaObs.setDisabled(true);
                botonObservaciones.setDisabled(true);
                botonAprobar.setDisabled(true);
                areaMotivoRechazo.setReadonly(true);
                botonRechazar.setDisabled(true);
                
                botonDesactivar.setDisabled(true);                
                buttonActiv.setDisabled(true);
                textComentarios.setReadonly(true);
                listAutoriza.setDisabled(true);
                calendarActivacion.setDisabled(true);
            }
            if(resultado.equals("ACTIVA")){
                textAreaObs.setReadonly(true);
                calendarFechaObs.setDisabled(true);
                botonObservaciones.setDisabled(true);
                botonAprobar.setDisabled(true);
                areaMotivoRechazo.setReadonly(true);
                botonRechazar.setDisabled(true);
                buttonActiv.setDisabled(true);
            }
            if(resultado.equals("INACTIVA")){
                textAreaObs.setReadonly(true);
                calendarFechaObs.setDisabled(true);
                botonObservaciones.setDisabled(true);
                botonAprobar.setDisabled(true);
                areaMotivoRechazo.setReadonly(true);
                botonRechazar.setDisabled(true);
                botonDesactivar.setDisabled(true);
            }
        }catch(Exception e){
            e.getStackTrace();
        }
        
        
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }
    
    private LineaInvestigacionBO lineaInvBO;
    private List<ParAcademicoVO> listaPares = new ArrayList<ParAcademicoVO>();
    private LineaInvestigacionVO lineaInvestigacionVO;
    private EstadoComplementoLineaInvVO estCompLineaVO;
    private ParAcademicoVO parAcademicoVO;
    private PersonaVO personaVO;
    
    private String observaciones="", motivoRechazo="", comentarios="";
    private int autoriza=0, idEstado=0, idLinea=0;
    private Date fechaObservaciones=null, fechaRechazo=null, fechaActivacion=null;




    /**
     * Modificado por Jimmy Ramírez
     * Ingresa las observaciones a una linea de investigación especifica
     * @return
     */

    public String botonObservaciones_action() {       
        lineaInvBO = new LineaInvestigacionBO();       
        estCompLineaVO = new EstadoComplementoLineaInvVO();
        try {                   
            idLinea = (Integer) hiddenIdLinea.getValue();
            observaciones = (String) textAreaObs.getValue();
            java.util.Date fechaObs = (java.util.Date) calendarFechaObs.getValue();
            if(observaciones==null || observaciones.equals("")){
                error("Por favor digite las observaciones del rechazo.");
                return null;
            }else if(fechaObs==null){
                error("Por favor seleccione la fecha de las observaciones.");
                return null;
            }else{
            fechaObservaciones = new Date(fechaObs.getTime());
            estCompLineaVO.setIdLinea(idLinea);
            estCompLineaVO.setComentarios(observaciones);
            estCompLineaVO.setFechaComentarios(fechaObservaciones);
            lineaInvBO.ingresarObservaciones(estCompLineaVO);
            info("Observaciones ingresadas correctamente");
            }         
        } catch (Exception e) {        
           e.printStackTrace();
           error("Error al ingresar observaciones a la linea");
        }
        return "OK";
    }

    public String botonAprobar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        // Try Catch Exception
        // This clip shows how to create a try/catch
        // statement to handle possible exceptions
        String resultado="";
        try {
          // TODO: Insert logic that may cause an exception
          // for example, performing database logic or file access
            lineaInvBO = new LineaInvestigacionBO();
            estCompLineaVO = new EstadoComplementoLineaInvVO();
            idLinea = (Integer) hiddenIdLinea.getValue();
            java.util.Date fechaActual = new java.util.Date();
            fechaActivacion = new Date(fechaActual.getTime());
            estCompLineaVO.setIdLinea(idLinea);
            estCompLineaVO.setFechaActivacion(fechaActivacion);
            resultado=lineaInvBO.aprobarLineaInv(estCompLineaVO);
            if(resultado.equals("se aprobo")){
                info("La linea de Investigación ha sido aprobada correctamente.");
                botonRechazar.setDisabled(true);
            }else{
                error("Error al aprobar la Linea de Investiagación.");
            }            
        } catch (Exception e) {
           // print exception information in the server log
           e.getStackTrace();
           error("error al aprobar la linea.");
        }
        return "OK";
    }

    public String botonRechazar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        // Try Catch Exception
        // This clip shows how to create a try/catch
        // statement to handle possible exceptions
        String resultado="";
        try {
          // TODO: Insert logic that may cause an exception
          // for example, performing database logic or file access
            lineaInvBO = new LineaInvestigacionBO();
            estCompLineaVO = new EstadoComplementoLineaInvVO();
            idLinea = (Integer) hiddenIdLinea.getValue();
            motivoRechazo = (String) areaMotivoRechazo.getValue();
            fechaRechazo = (Date) textFechaRechazo.getValue();
            
            if(motivoRechazo==null || motivoRechazo.equals("")){
                error("Por favor digite el motivo por el cual va a rechazar la Linea de investigación.");
                return null;
            }            
            estCompLineaVO.setIdLinea(idLinea);
            estCompLineaVO.setMotivoRechazo(motivoRechazo);
            estCompLineaVO.setFechaRechazo(fechaRechazo);
            resultado=lineaInvBO.rechazarLineaInv(estCompLineaVO);
            if(resultado.equals("rechazada")){
                info("La linea de investigación ha sido rechazado correctamente.");
                botonAprobar.setDisabled(true);
            }else{
                error("Error al rechazar la Linea de Investigación.");
            }
            
        } catch (Exception e) {
           // print exception information in the server log
           e.getStackTrace();
           error("error al aprobar la linea.");
           // view log messages using View Server Log menu item 
           // on the Deployment Server node in the Server Navigator
           // TODO: either handle the exception or pass it to the Faces layer
           // throw new FacesException(e);
        }
        return "OK";
    }

    public String buttonActiv_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        // Try Catch Exception
        // This clip shows how to create a try/catch
        // statement to handle possible exceptions
        String resultado="";
        try {
          // TODO: Insert logic that may cause an exception
          // for example, performing database logic or file access
            lineaInvBO = new LineaInvestigacionBO();
            estCompLineaVO = new EstadoComplementoLineaInvVO();
            
            idLinea = (Integer) hiddenIdLinea.getValue();
            comentarios = (String) textComentarios.getValue();
            String aut = (String) listAutoriza.getValue();
            autoriza = Integer.parseInt(aut);
            java.util.Date fechaAct = (java.util.Date) calendarActivacion.getValue();
            
            if(autoriza==0){
                error("Por favor seleccione a un integrante para realizar la acticación.");
                return null;
            }if(fechaAct==null){
                error("por favor seleccione la fecha..");
                return null;
            }
            fechaActivacion = new Date(fechaAct.getTime());
            estCompLineaVO.setIdLinea(idLinea);
            estCompLineaVO.setComentarios(comentarios);
            estCompLineaVO.setAutoriza(autoriza);
            estCompLineaVO.setFechaActivacion(fechaActivacion);
            resultado=lineaInvBO.activarLineaInv(estCompLineaVO);
            if(resultado.equals("activado")){
                info("La linea de investigación ha sido activada correctamente.");
            }else{
                error("Error al activar Línea.");
            }
            botonDesactivar.setDisabled(false);
        } catch (Exception e) {
           // print exception information in the server log
           log("Exception Message!!!", e);
           error("Error no esperado al activar Línea.");
        }
        return null;
    }

    public String botonDesactivar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        // Try Catch Exception
        // This clip shows how to create a try/catch
        // statement to handle possible exceptions
        String resultado="";
        try {
          // TODO: Insert logic that may cause an exception
          // for example, performing database logic or file access
            lineaInvBO = new LineaInvestigacionBO();
            estCompLineaVO = new EstadoComplementoLineaInvVO();
            
            idLinea = (Integer) hiddenIdLinea.getValue();
            comentarios = (String) textComentarios.getValue();
            String aut = (String) listAutoriza.getValue();
            autoriza = Integer.parseInt(aut);
            java.util.Date fechaAct = (java.util.Date) calendarActivacion.getValue();
            
            if(autoriza==0){
                error("Por favor seleccione a un integrante para realizar la acticación.");
                return null;
            }if(fechaAct==null){
                error("por favor seleccione la fecha..");
                return null;
            }
            
            fechaActivacion = new Date(fechaAct.getTime());
            estCompLineaVO.setIdLinea(idLinea);
            estCompLineaVO.setComentarios(comentarios);
            estCompLineaVO.setAutoriza(autoriza);
            estCompLineaVO.setFechaActivacion(fechaActivacion);
            resultado=lineaInvBO.inactivarLineaInv(estCompLineaVO);
            if(resultado.equals("desactivado")){
                info("La linea de investigación ha sido desactivada correctamente.");
            }else{
                error("Error al desactivar la Línea.");
            }
            buttonActiv.setDisabled(false);
        } catch (Exception e) {
           // print exception information in the server log
           error("Error no esperado al desactivar Línea.");
        }
        return "OK";
    }

    public String botonCancelar1_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        lineaInvestigacionVO = new LineaInvestigacionVO();
        idLinea= (Integer) hiddenIdLinea.getValue();
        lineaInvestigacionVO.setIdLinea(idLinea);
        getRequestBean1().setLineaInvVO(lineaInvestigacionVO);
        return "consultarLinea";
    }

    public String botonCancelar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        lineaInvestigacionVO = new LineaInvestigacionVO();
        idLinea= (Integer) hiddenIdLinea.getValue();
        lineaInvestigacionVO.setIdLinea(idLinea);
        getRequestBean1().setLineaInvVO(lineaInvestigacionVO);
       return "consultarLinea";
    }

    public String tab1_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public String tab2_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }
    
}

